var app = getApp()
var axios = require("../../utils/core")
Page({

    /**
     * 页面的初始数据
     */
    data: {
        type: '0',
        listTab: [],
        list: [],
        openid: "",
        listTableve: [],
        leves: {}
    },
    tab(e) {
        this.setData({
            type: e.currentTarget.dataset.type
        })
        if (e.currentTarget.dataset.type == 0) {
            var that = this
            axios.post("goods.hyxxk_goods", {
                openid: that.data.openid,
                levelid:5
            }, ((e) => {
                that.setData({
                    list: e
                })
            }))
        } else if (e.currentTarget.dataset.type == 1) {
            var that = this
            axios.post("goods.hyxxk_goods", {
                openid: that.data.openid,
                levelid:6
            }, ((e) => {
                that.setData({
                    list: e
                })
            }))
        } else if (e.currentTarget.dataset.type == 2) {
            var that = this
            axios.post("goods.hyxxk_goods", {
                openid: that.data.openid,
                levelid:7
            }, ((e) => {
                that.setData({
                    list: e
                })
            }))
        } else if (e.currentTarget.dataset.type == 3) {
            var that = this
            axios.post("goods.hyxxk_goods", {
                openid: that.data.openid,
                levelid:8
            }, ((e) => {
                that.setData({
                    list: e
                })
            }))
        }

    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var openid = wx.setStorageSync('openid')
        var leves = wx.getStorageSync('leves')
        this.setData({
            openid: openid,
            leves: leves
        })
        //页面加载获取tab数据 
        axios.post("goods.hyxxk", {
            openid: this.data.openid,
        }, ((e) => {
            var that = this
            that.setData({
                listTab: e.list
            })
        }))
        //页面加载获取商品数据 type=0 创客数据
        axios.post("goods.hyxxk_goods", {
            openid: this.data.openid,
            levelid:5
        }, ((e) => {
            var that = this
            console.log("商品数据", e);
            that.setData({
                list: e
            })
        }))
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})